<template>
	<view class="content">
		<view class="body">
			<view>
				<button type="primary" @click="addRecord">新增记录</button>
			</view>
			<view class="record-page">
				<scroll-view  scroll-y="true" class="scroll-Y" 
				 :refresher-enabled = "refresherEnabled"
				 :refresher-triggered="triggered"
				@refresherpulling="onPulling">
					<view class="detai-row" v-for="(record) in recordList">
						<view class="row-view">
							<text class="txt-date">{{record.createDate}}</text>
							<text class="txt-stts" v-if="record.recordType==1">待核对</text>
							<text class="txt-stts" v-if="record.recordType==2">已核查</text>
							<text class="txt-stts" v-if="record.recordType==3">已发工资</text>
						</view>
						<view class="record-view">
							<view class="rcord-item">订单号:{{record.id}}</view>
							<view class="rcord-item">客户姓名：{{record.custName}}</view>
							<view class="rcord-item">项目名称：{{record.configName}}</view>
							<view class="rcord-item">总金额：{{record.totalAmount}}</view>
							<view class="rcord-item">优惠金额：{{record.discountAmount}}</view>
							<view class="rcord-item">收费金额：现金 {{record.totalCashAmount}} 电子 {{record.totalCardAmount}}</view>
							<view class="rcord-item">小费金额： {{record.tipsCardAmount}} </view>
							<view class="rcord-item">分成比例:{{record.technicianRate}}%</view>
							<view class="rcord-item">分成金额：现金 {{record.techCashAmount}} 电子 {{record.techCardAmount + record.tipsCardAmount }}</view>
							<view class="rcord-item">刷卡备注：{{record.cardRemark}}</view>
							<view class="rcord-item">备注：{{record.recordRemark}}</view>
						</view>
						<view class="record-floor" v-if="record.recordType==1">
							<view class="record-button" @click="edit(record.id)">编辑</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import {findMyPage} from '@/api/index'
	export default {
		data() {
			return {
				triggered: false,
				recordList: [],
				totalPages: 0,
				refresherEnabled:true,
				param: {
					pageNum: 1,
					pageSize: 10
				}
			}
		},
		created: function() {
			this.findMyRecordPage();
		},
		methods: {
			addRecord() {
				this.$tab.navigateTo('/pages/record/add')
			},
			findMyRecordPage() {
				this.param.timeType = 1;
				let _this = this;
				findMyPage(this.param).then(res => {
					if (res.data != undefined && res.data.length > 0) {
						this.totalPages = res.totalPage;
						for (var i = 0; i < res.data.length; i++) {
							this.recordList.push(res.data[i]);
						}
					}
					_this.triggered = false;
				})
			},
			edit(id) {
				this.$tab.navigateTo('/pages/record/add?id=' + id);
			},
			onPulling(e) {
				this.param.pageNum += 1;
				if (this.param.pageNum <= this.totalPages) {
					this.findMyRecordPage();
				} else {
					this.refresherEnabled = false;
				}
			}
		},
	}
</script>

<style>
	page {
		background-color: #f5f8fc;
	}

	.content {
		margin: 4px 8px;

	}

	.record-page {
		margin-top: 10px;
	}

	.detai-row {
		background-color: #ffffff;
		display: flex;
		border-radius: 4px;
		flex-wrap: wrap;
		margin-top: 10px;
		padding-bottom: 10px;
	}

	.detai-row .row-view {
		display: flex;
		width: 100%;
		height: 36px;
		align-items: center;
		font-size: 16px;
		padding: 0px 10px 0px 10px;
		border-bottom: 1px solid #f6f6f6;
	}

	.detai-row .row-view .txt-stts {
		display: flex;
		flex: 1;
		justify-content: flex-end;
	}

	.detai-row .record-view {
		width: 100%;
		height: 36px;
		display: inline-table;
		align-items: center;
		font-size: 15px;
	}

	.detai-row .record-view .rcord-item {
		padding: 2px 0;
		margin-left: 5px;
	}

	.detai-row .record-floor {
		display: flex;
		height: 36px;
		align-items: center;
		font-size: 16px;
		padding: 0px 10px 0px 10px;
		border-top: 1px solid #f6f6f6;
		flex: 1;
		justify-content: flex-end;
		align-items: center;
		padding: 10px 0px;
		margin-right: 10px;
	}

	.detai-row .record-floor .record-button {
		padding: 4px 11px;
		border-radius: 23px;
		color: red;
		border: 1px solid red;
	}
	
	.scroll-Y {
			height: 90%;
		}
		.scroll-view_H {
			white-space: nowrap;
			width: 100%;
		}
		.scroll-view-item {
			height: 300rpx;
			line-height: 300rpx;
			text-align: center;
			font-size: 36rpx;
		}
		.scroll-view-item_H {
			display: inline-block;
			width: 100%;
			height: 300rpx;
			line-height: 300rpx;
			text-align: center;
			font-size: 36rpx;
		}
</style>